import * as THREE from 'three'
// 场景的背景
export class BackGround {
  constructor(scene) {
    this.scene = scene
    this.url = 'src/assets/black-bg.png'
    this.init()
  }
  // 创建天空盒子
  init() {
    // 创建一个纹理加载器
    const loader = new THREE.TextureLoader()
    // 创建一个球体
    const geometry = new THREE.SphereGeometry(5000, 32, 32)
    const materail = new THREE.MeshBasicMaterial({
      side: THREE.DoubleSide,
      map: loader.load(this.url)
    })
    const sphere = new THREE.Mesh(geometry, materail)
    sphere.position.copy({
      x: 0,
      y: 0,
      z: 0
    })
    this.scene.add(sphere)
  }
}
